<template>
	<view class="P_2">
		<view class="B_radius_5 P_2 flex_rowC">
			<view class="MR_4 PB_1" :key='i' v-for="(item,i) in lianList" :class="idx1==i?'line_red':''" @click="lianChange(i,item)">
				{{item}}
			</view>	
		</view>
		<view class="bg_fff P_2 B_radius_5 ">
			<view class="flex_row_between line_bom PTB_2" v-for="(item,i) in list" :key='i'>
				<view class="W_60vw">
					<view class="">
						{{item.nickname}}
					</view>
					<view class="W_60vw">
						{{item.address}}
					</view>
				</view>
				<view class="flex_rowL">
					<!-- <view class="line_right PR_2" @click="chooseAds(item)">
						选择	
					</view> -->
					<view class="color_red PL_2" @click="deletList(item)">
						删除
					</view>
				</view>
			</view>
		</view>
		<!-- <view class="PTB_2 pub_bg B_radius_5 color_fff flex_rowC MT_4" @click="checkPass('./editbili?id=5'+'&mId=edit')">
			新增地址
		</view> -->
		<view class="PTB_2 pub_bg B_radius_5 color_fff flex_rowC MT_4" @click="goEdibili">
			新增地址
		</view>
		<uni-popup ref="popups" type="center">
			<view class="W_60vw bg_fff B_radius_5">
				<view class="flex_rowC PTB_4">
					安全密码
				</view>
				<view class="PTB_1 MLR_5 flex_rowC MB_3 B_radius_5" style="border: 1px solid #C7C7C7;">
					<input class="textC" v-model="pass" type="password" value="" />
				</view>
				<view class="flex_row_between" style="border-top: 1px solid #cecece">
				  <view
					@click="$refs.popups.close()"
					class="flex_rowC PTB_3"
					style="width: 50%; border-right: 1px solid #cecece"
				  >
					取消
				  </view>
				  <view @click="goCheck()" style="width: 50%" class="flex_rowC color_red">
					确认
				  </view>
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="popup" type="center">
			<view class="W_60vw PT_4 bg_fff B_radius_10">
				<view class="flex_rowC PB_6">
					确定要删除吗
				</view>
				<view class="flex_row_between PTB_2" style="border-top:1px solid #F8F8F8">
					<view @click="$refs.popup.close()" class=" flex_rowC W_30vw" style="border-right: 1px solid #F8F8F8;">
						取消
					</view>
					<view class="flex_rowC W_30vw color_red" @click="goDel">
						确定
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:'',
				type:'',
				list:[],
				delId:'',
				idx1:0,
				mId:'',
				biDet:{},
				lianList:[],
				lian:'',
				jumpUrl:'',
				pass:''
			}
		},
		onLoad(options) {
			console.log(options.id)
			//console.log(options.type)
			this.id = options.id;
			this.mId = options.moneyId;
			// this.getBi();
			this.getList()
		},
		methods: {
			checkPass(i){
				this.jumpUrl = i;
				this.$refs.popups.open();
				
			},
			goCheck(){
				if(!this.pass){
					this.toast('请输入安全密码')
				}else{
					let _this = this;
					// if(_this.delId){
					// 	_this.$refs.popups.close();
					// 	_this.$refs.popup.close();
					// }else{
						this.$req('user/checkPaypwd',{paypwd:_this.pass},function(res){
							_this.pass = ''
							_this.$refs.popups.close();
							_this.$refs.popup.open();
							// _this.uOpenWin()
						})
					// }
					
				}
			},
			
			goEdibili(){
				console.log(111)
				uni.navigateTo({
					url:"/pages/mine/editbili?id=5&mId=edit"
				})
			},
			
			lianChange(i,item){
				this.idx1 = i;
				this.type = item;
				this.getList()
			},
			goDel(){
				let _this = this;
				this.$req('taddress/delete',{id:_this.delId},function(res){
					if(res.code==1){
						_this.delId='';
						_this.$refs.popup.close()
						_this.toast('删除成功');
						_this.getList();
					}else{
						_this.toast(res.msg)
					}
				})
			},
			getBi(){
				let _this = this;
				this.$req('account/show',{id:_this.mId},function(res){
					if(res.code==1){
						_this.biDet = res.data;
						_this.lianList = res.data.currency.chain_arr;
						_this.type = res.data.currency.chain_arr[0];
						_this.getList();
					}else{
						_this.toast(res.msg)
					}
				})
			},
			deletList(item){
				this.delId = item.id;
				this.$refs.popups.open()
				// let _this = this;
				// this.$req('taddress/delete',{id:item.id},function(res){
				// 	if(res.code==1){
				// 		_this.toast('删除成功');
				// 		_this.getList();
				// 	}else{
				// 		_this.toast(res.msg)
				// 	}
				// })
			},
			chooseAds(item){
				console.log(item)
				this.uOpenWin('./cashOut?adsId='+item.id+'&way=getAds&id='+this.mId+'&curreyid='+item.currency_id)
			},
			getList(){
				let _this = this;
				this.$req('taddress/index',{currency_id:'5',chain:'TRC20'},function(res){
					if(res.code==1){
						_this.list = res.data.list;
					}else{
						_this.toast(res.msg)
					}
				})
			}
		}
	}
</script>

<style>
	view{
		word-wrap: break-word;
		word-break: break-all;
		white-space: pre-line;
	}
.line_right{
	border-right: 1px solid #cecece;
	}
.line_red{
	border-bottom: 2px solid red;
}
</style>
